<?php
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/art-dialog/jquery.artDialog.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/art-dialog/plugins/iframeTools.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/post/uploadify/jquery.uploadify.min.js",CClientScript::POS_HEAD);
?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/css/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/js/art-dialog/skins/blue.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/js/post/uploadify/uploadify.css">
<div class="st-form-line">
    <?php
    $fileType = $filePrompt = $fileExecute = '';
    if($type){
        $types = explode('-',$type);
        foreach($types as $v){
            $fileType .='*.'.$v.';';
            $filePrompt .= $v.' ';
            $fileExecute .= $v.',';
        }

    }
    ?>
<form>
  <input id="uploadify" name="uploadify" type="file" multiple="true">您可以上传<?php echo $filePrompt ?>类型文件
    <ul id="fileListWarp">
    </ul>
  <div id="fileQueue" style="clear:both"></div>
</form>
    </div>

<script type="text/javascript">
		
$(function() {
    $('#uploadify').uploadify({
        'buttonText': '选择文件..',
        'fileObjName': 'imgFile',
        'method': 'post',
        'multi': true,
		'queueID': 'fileQueue',
        'uploadLimit': 1,
        'fileTypeExts': '<?php echo $fileType ?>',
        'buttonImage': '<?php echo $this->adminPath; ?>/js/post/uploadify/select.png',
        'formData': {
            'sessionId'   : '<?php echo session_id(); ?>',
			'timestamp'   : '<?php echo time();?>',
			'token'       : '<?php echo md5('unique_salt'.time()); ?>',
            'filetype'    : '<?php echo trim($fileExecute,","); ?>'
        },
        'swf': '<?php echo $this->adminPath; ?>/js/post/uploadify/uploadify.swf',
        'uploader': '<?php echo Yii::app()->createAbsoluteUrl('admin/uploadify/fileExecute')?>',
        'onUploadStart': function(file) {
            $('#uploadify').uploadify('settings', 'formData', {
                'iswatermark': $("#iswatermark").attr("checked")
            });
        },
        'onUploadSuccess': function(file, data, response) {
            var json = $.parseJSON(data);
            if (json.state == 'success') {

                $("#fileListWarp").html('<li id="image_' + json.fileId + '">' +
                    '<img src="<?php echo $this->adminPath; ?>/img/icons/dashbutton/documents.png" width="40" height="40"  align="absmiddle"/></li>');
                art.dialog.data('fileListWarp',json.file);
            } else {
                alert(json.message);
            }
        }
    });
});





	</script>
